﻿using UnityEngine;
using System.Collections;

public class BossLogic : MonoBehaviour {


    public delegate void BossEvent();
    public event BossEvent onSpecialAttack = null;
    public event BossEvent onNormalAttack = null;
    public event BossEvent onCrazyAttack = null;

    public float attackInterval = 0f;

    private int attackTimes = 0;
    private float timeDelta = 0;

    // Use this for initialization
    void Start () {
	    
	}
	
	// Update is called once per frame
	void Update () {

        timeDelta += Time.deltaTime;

        if (timeDelta >= attackInterval) {
            timeDelta = 0;
            if (GetComponent<BossSTM>().status == GameConfig.BOSS_STM_CRAZY)
            {
                if (onCrazyAttack != null)
                    onCrazyAttack.Invoke();
            }
            else {
                if (attackTimes % GameConfig.SPECIAL_ATTACK_INTERVAL == 0) {
                    if (onSpecialAttack != null)
                        onSpecialAttack.Invoke();
                }
                else {
                    if (onNormalAttack != null)
                        onNormalAttack.Invoke();
                }
                attackTimes += 1;
            }
        }
	}
}
